<?php
 require_once('m_ajax.php');
 
 $p = $_POST;
 
 switch($p['function'])
 {
   case 'replaceh1':
   		$temp = explode(',', $p['current']);
   		$current_id = $temp[1];
   		$order = $temp[0];
   		$temp = explode(',', $p['replacement']);
   		$replacement_id = $temp[1];
   		$rorder = $temp[0];
		   $post['h1'] = $rorder;		   
			process_sql_post($post,'content_post','update','id',$current_id);
			$post['h1'] = $order;
			process_sql_post($post,'content_post','update','id',$replacement_id);
   break;
   case 'replaced1':
   		$temp = explode(',', $p['current']);
   		$current_id = $temp[1];
   		$order = $temp[0];
   		$temp = explode(',', $p['replacement']);
   		$replacement_id = $temp[1];
   		$rorder = $temp[0];
		   $post['d1'] = $rorder;		   
			process_sql_post($post,'content_post','update','id',$current_id);
			$post['d1'] = $order;
			process_sql_post($post,'content_post','update','id',$replacement_id);
   break;
   case 'replace-wa':
   		$temp = explode(',', $p['current']);
   		$current_id = $temp[1];
   		$order = $temp[0];
   		$temp = explode(',', $p['replacement']);
   		$replacement_id = $temp[1];
   		$rorder = $temp[0];
		   $post['w'] = $rorder;		   
			process_sql_post($post,'content_post','update','id',$current_id);
			$post['w'] = $order;
			process_sql_post($post,'content_post','update','id',$replacement_id);
   break;
   case 'add-count':
   		$sname = $p['type']."-count-".$p['page'];
			mp($sname);
   		$count = (int)$p['count'];
			$post['setting_value']=$count+1;   
			process_sql_post($post,'settings','update','setting_name',$sname);
   break;
   case 'remove-count':
   		$sname = $p['type']."-count-".$p['page'];
			mp($sname);
   		$count = (int)$p['count'];
			$post['setting_value']=$count-1;   
			process_sql_post($post,'settings','update','setting_name',$sname);
   break;
   	
 } 


echo json_encode($data);
?>
